# -*- coding: utf-8 -*-
import scrapy


class DbsgwlogininfoSpider(scrapy.Spider):
    name = 'dbsgwlogininfo'
    allowed_domains = ['dbsgw.cn']
    start_urls = ['https://blog.dbsgw.cn/admin/']

    def parse(self, response):
        post_data = {
            "user": "admin",
            "pw": "062823"
        }
        yield scrapy.FormRequest(
            url='https://blog.dbsgw.cn/admin/index.php?action=login',
            callback=self.logininfo,
            formdata=post_data
        )

    def logininfo(self, response):
        print(response.xpath('//*[@id="page-wrapper"]/div[1]/b/text()').get())
        yield scrapy.Request('https://blog.dbsgw.cn/admin/configure.php', callback=self.loginview)

    def loginview(self, response):
        print(response.xpath('//*[@id="input"]/div[2]/textarea/text()').get())
